<#assign module="workcar"/>

<@override name="header">
</@override>
<@override name="body">

	<div class="row">
		<div class="col-md-12">
			<div class="panel panel-default">
				<div class="panel-heading">
					编辑工作区域
			    </div>
			    <div class="panel-body">
			    <form id="submit_form" action="${ctx}/workcararea/update" class="form-horizontal" method="post">
			         <div class="col-sm-6">
		                    	<div class="panel panel-default" style="position:relative;">
									<div class="panel-heading">
										<span>1.在地图中点击右键。 2.选择设为行驶地添加路线</span>
									</div>
								    <div id="allmap" style="z-index: 999; height:500px;">
					        		</div>
					        	</div>
		             </div>
		             <div class="col-sm-6">
		                <input type="hidden" id="id" name="id" value="${workcararea.id}">
		                <@shiro.isMainCompany>	
				      		<div class="form-group">
				                <label class="col-sm-4 control-label">所属公司:</label>
				                <div class="col-sm-6">
					                <select class="form-control" id="companyId" >
										<#if companys??>
											<option value="">请选择公司</option>
											<#list companys as company>
												<option value="${company.id}" <#if companyId?? && companyId==company.id>selected="selected"</#if>>${company.abbreviation?if_exists}</option>
											</#list>
										</#if>
									</select>
				                </div>
							 </div>
						</@shiro.isMainCompany>	
		                <div class="form-group">
		                    <label class="col-sm-4 control-label"><em>*</em>城市：</label>
		                    <div class="col-sm-6">
		                    	<input class="form-control" id="city" name="city" type="text" value="${workcararea.city?if_exists}" required/>
		                    </div>
		                </div>
		                
		                <div class="form-group">
		                    <label class="col-sm-4 control-label"><em>*</em>路线名：</label>
		                    <div class="col-sm-6">
		                    	<input class="form-control" id="name" name="name" type="text" value="${workcararea.name?if_exists}" required/>
		                    </div>
		                    <#-- <div class="col-sm-3">
				                    <div class="input-group">
					                    <input class="form-control"  placeholder="添加地点" type="text" id="address" value="" autocomplete="off"/>
					                    <span class="input-group-btn">
				                            <button class="btn btn-default" type="button" id="position">定位</button>
					                    </span>
				                    </div>
						     </div> -->
		                </div>
		                
		                <div class="form-group">
		                	  <label class="col-sm-4 control-label"><em>*</em>选择路线：</label>
		                	<div class="col-sm-6" id="list">
                                 <#if workcararea.waypoints??>
							        <#list workcararea.waypoints as way>
							         <#if way_index==0>
								        <div>
					                	      <div class="col-sm-10" style="margin-left:-15px;">
								                    <input class="form-control address" onblur="position(this)" placeholder="添加地点" index="${way_index}" type="text" id="address" value="${way.address}" autocomplete="off"/>
								              </div>
								              <div>
									               <button  type="button" id="add"   class="btn btn-default btn-sm" title="添加">
				                                         <span class="glyphicon glyphicon-plus"></span> 
				                                    </button>
			                                  </div>  
		                                </div>    
	                                	 <p/>
	                                  <#else>
	                                   <div>
		                                   <div class="col-sm-10" style="margin-left:-15px;">
						                     <input class="form-control address" onblur="position(this)" placeholder="添加地点" type="text" id="wayAddress"  index="${way_index}" value="${way.address}" autocomplete="off"/>
						                   </div>
						                   <div>
							                   <button  type='button'class='sub btn btn-default btn-sm' title='删除'>
			                                        <span class='glyphicon glyphicon-minus'></span>
			                                   </button>
		                                   </div>
	                                   </div>
					                  <p/>
                                	 </#if>
							           
							        </#list>
							     </#if> 
                                  
                                    
					        </div>
		                </div>
		              </div>  
					</form>
        		</div>
        		<div class="row">
	        		 <div class="form-group" style="margin-left:10px;">
				                <label class="col-sm-3 control-label"></label>
				                <input type="button" class="btn btn-primary" id="submit" value="保存">
				                <input type="button" class="btn btn-default" id="rollback" onclick="window.location.href = '${ctx}/workcararea/list';" value="返回">
				     </div>
				 </div>
			</div>
		</div>
	</div>

</@override>
<@override name="footer">
<script type="text/javascript">
  var waypoints=[];
  var obj=null;
      <#if workcararea.waypoints??>
        <#list workcararea.waypoints as way>
         obj = new Object();
         obj.address="${way.address}";
         obj.lng=${way.longitude};
         obj.lat=${way.latitude};
         waypoints[${way_index}]=obj;
        </#list>
      </#if>
	window.daijia = {
		ctx:'${ctx}',
		center:'${address?if_exists}',
		areaId:'${workcararea.id}',
		waypoints:waypoints,
		edit:true
	};
</script>
<script src="//api.map.baidu.com/api?v=2.0&ak=AuNk3YS21DSmHEEvIFDf9dbD" type="text/javascript"></script> 
<script src="${ctx}/assets/js/addmorenewworkcararea.js"></script>
</@override>
<@extends name="../layout.ftl"/>